package org.studiox.graph.persistence.spring.jdbc.rowmapper;

import org.springframework.jdbc.core.RowMapper;
import org.studiox.graph.persistence.model.GraphEdgeDO;

import java.sql.ResultSet;
import java.sql.SQLException;

public class GraphEdgeDOMapper implements RowMapper<GraphEdgeDO> {

  @Override
  public GraphEdgeDO mapRow(ResultSet rs, int rowNum) throws SQLException {
    GraphEdgeDO graphEdgeDO = new GraphEdgeDO();
    graphEdgeDO.setId(rs.getLong("id"));
    graphEdgeDO.setContent(rs.getString("content"));
    graphEdgeDO.setContentMd5(rs.getString("content_md5"));
    graphEdgeDO.setType(rs.getString("type"));
    graphEdgeDO.setOwner(rs.getString("owner"));
    graphEdgeDO.setSourceVertexUniq(rs.getString("source_vertex_uniq"));
    graphEdgeDO.setTargetVertexUniq(rs.getString("target_vertex_uniq"));
    graphEdgeDO.setJanusEdgeId(rs.getString("janus_edge_id"));
    graphEdgeDO.setNeo4jEdgeId(rs.getLong("neo4j_edge_id"));
    graphEdgeDO.setNebulaEdgeId(rs.getString("nebula_edge_id"));
    graphEdgeDO.setSourceJanusVertexId(rs.getLong("source_janus_vertex_id"));
    graphEdgeDO.setTargetJanusVertexId(rs.getLong("target_janus_vertex_id"));
    graphEdgeDO.setSourceNeo4jVertexId(rs.getLong("source_neo4j_vertex_id"));
    graphEdgeDO.setTargetNeo4jVertexId(rs.getLong("target_neo4j_vertex_id"));
    graphEdgeDO.setSourceNebulaVertexId(rs.getLong("source_nebula_vertex_id"));
    graphEdgeDO.setTargetNebulaVertexId(rs.getLong("target_nebula_vertex_id"));
    graphEdgeDO.setDeleted(rs.getBoolean("deleted"));
    graphEdgeDO.setCreateTime(rs.getTimestamp("create_time"));
    graphEdgeDO.setUpdateTime(rs.getTimestamp("update_time"));
    return graphEdgeDO;
  }
}
